<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{:t('会员')}编辑</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<script src="__STATIC__/admin/js/address3.js"></script>
	<style>
		.layui-form-label{width:130px!important}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
			<div class="layui-card layui-col-md12">
				<div class="layui-card-header"><i class="fa fa-edit"></i> {:t('会员')}编辑<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i></div>
        <div class="layui-card-body" pad15>
					<div class="layui-form" lay-filter="form">
						<input type="hidden" name="info[id]" value="{$info.id}"/>
						<div class="layui-tab layui-tab-brief" lay-filter="mytab">
							<ul class="layui-tab-title">
								<li class="layui-this" lay-id="1">基本信息</li>
								{if getcustom('register_fields')}<li lay-id="2">扩展信息</li>{/if}
							</ul>
						<div class="layui-tab-content">
						<!--基本信息start-->
						<div class="layui-tab-item layui-show">
						{if $info['mpopenid']}
						<div class="layui-form-item">
							<label class="layui-form-label">公众号openid</label>
							<div class="layui-form-mid">{$info.mpopenid}</div>
						</div>
						{/if}
						{if $info['wxopenid']}
						<div class="layui-form-item">
							<label class="layui-form-label">微信小程序openid</label>
							<div class="layui-form-mid">{$info.wxopenid}</div>
						</div>
						{/if}
						{if getcustom('xixie')}
						<div class="layui-form-item">
							<label class="layui-form-label">门店</label>
							<div class="layui-input-inline">
								<select name="info[mdid]" lay-filter="yxqset" class="levelid">
									<option value="" >无</option>
									{foreach $mendian as $v}
									<option value="{$v.id}" {if $v['id'] == $info['mdid']}selected{/if}>{$v.name}</option>
									{/foreach}
								</select>
							</div>
						</div>
						{/if}
						<div class="layui-form-item">
							<label class="layui-form-label">头像</label>
							<input type="hidden" name="info[headimg]" id="headimg" class="layui-input" value="{$info.headimg}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="headimg" upload-preview="headimgPreview" onclick="uploader(this)">上传图片</button>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：150×150像素</div>
							<div id="headimgPreview" style="float:left;padding-top:10px;margin-left:160px;clear: both;">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.headimg}"/></div></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">昵称</label>
							<div class="layui-input-inline">
								<input type="text" name="info[nickname]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.nickname}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">姓名</label>
							<div class="layui-input-inline">
								<input type="text" name="info[realname]" class="layui-input" value="{$info.realname}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">手机号</label>
							<div class="layui-input-inline">
								<input type="text" name="info[tel]" class="layui-input" value="{$info.tel}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">身份证号</label>
							<div class="layui-input-inline">
								<input type="text" name="info[usercard]" class="layui-input" value="{$info.usercard}">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">{:t('积分')}</label>
							<div class="layui-input-inline">
								<input type="text" name="info[score]" class="layui-input" value="{$info.score}">
							</div>
						</div>
						<div class="level-box">
							<div class="layui-form-item">
								<label class="layui-form-label">等级</label>
								<div class="layui-input-inline">
									<select name="info[levelid]" lay-verify="required" lay-filter="yxqset" class="levelid">
										{foreach $levelList as $v}
										<option value="{$v.id}" {if $v['id'] == $info['levelid']}selected{/if}>{$v.name}</option>
										{/foreach}
									</select>
								</div>
								<div id="yxqset" {if $defaultlevel['id'] == $info['levelid']}style="display:none"{/if}>
									<div class="layui-form-mid">有效期</div>
									<div class="layui-input-inline" id="levelendtime_div" style="{if $info['levelendtime']==0}display:none{/if}">
										<input type="text" name="info[levelendtime]" id="levelendtime" autocomplete="off" class="layui-input" value="{$info['levelendtime'] > 0 ? date('Y-m-d',$info['levelendtime']) : ''}">
									</div>
									<div class="layui-input-inline">
										<input type="checkbox" name="levelcq" value="1" {if $info['levelendtime']==0}checked{/if} title="长期" lay-filter="levelcq"/>
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">区域代理</label>
								<div class="layui-input-inline" style="width:700px">
									<input type="radio" name="info[areafenhong]" value="0" lay-filter="areafenhongChange" {if $info['areafenhong']==0}checked{/if} title="跟随会员等级设置"/>
									{if getcustom('areafenhong_jiaquan') && ($auth_data=='all' || in_array('Largearea/*',$auth_data))}
									<input type="radio" name="info[areafenhong]" value="10" lay-filter="areafenhongChange" {if $info['areafenhong']==10}checked{/if} title="大区代理"/>
									{/if}
									<input type="radio" name="info[areafenhong]" value="1" lay-filter="areafenhongChange" {if $info['areafenhong']==1}checked{/if} title="省级代理"/>
									<input type="radio" name="info[areafenhong]" value="2" lay-filter="areafenhongChange" {if $info['areafenhong']==2}checked{/if} title="市级代理"/>
									<input type="radio" name="info[areafenhong]" value="3" lay-filter="areafenhongChange" {if $info['areafenhong']==3}checked{/if} title="区县代理"/>
									<input type="radio" name="info[areafenhong]" value="4" lay-filter="areafenhongChange" {if $info['areafenhong']==4}checked{/if} title="非区域代理"/>
								</div>
							</div>
							<div class="layui-form-item areafenhong_address" {if ($info['areafenhong']==0 && $levelArr[$info['levelid']]['areafenhong']==0) || $info['areafenhong']==4}style="display:none"{/if}>
								<label class="layui-form-label">代理区域</label>
								{if getcustom('areafenhong_jiaquan') && ($auth_data=='all' || in_array('Largearea/*',$auth_data))}
								<div class="layui-input-inline areafenhong_largearea_div" {if ($info['areafenhong']==0 && $levelArr[$info['levelid']]['areafenhong']!=10) || in_array($info['areafenhong'],[1,2,3])}style="display:none"{/if}>
									<select name="info[areafenhong_largearea]" id="areafenhong_largearea">
										<option value="">请选择大区</option>
										{php} $largearealist = db('largearea')->where('aid',$aid)->where('status',1)->order('sort desc,id')->column('name');{/php}
										{foreach $largearealist as $largearea}
										<option value="{$largearea}" {if $info['areafenhong_largearea'] == $largearea}selected{/if}>{$largearea}</option>
										{/foreach}
									</select>
								</div>
								{/if}
								<div class="layui-input-inline areafenhong_province_div" {if ($info['areafenhong']==0 && !in_array($levelArr[$info['levelid']]['areafenhong'],[1,2,3])) || $info['areafenhong']==10}style="display:none"{/if}>
									<select name="info[areafenhong_province]" id="areafenhong_province" lay-filter="areafenhong_province"></select>
								</div>
								<div class="layui-input-inline areafenhong_city_div" {if ($info['areafenhong']==0 && !in_array($levelArr[$info['levelid']]['areafenhong'],[2,3])) || in_array($info['areafenhong'],[1,10])}style="display:none"{/if}>
									<select name="info[areafenhong_city]" id="areafenhong_city" lay-filter="areafenhong_city"></select>
								</div>
								<div class="layui-input-inline areafenhong_area_div" {if ($info['areafenhong']==0 && $levelArr[$info['levelid']]['areafenhong']!=3) || in_array($info['areafenhong'],[1,2,10])}style="display:none"{/if}>
									<select name="info[areafenhong_area]" id="areafenhong_area"></select>
								</div>
							</div>
							<div class="layui-form-item areafenhong_bili" {if !in_array($info['areafenhong'],[1,2,3])}style="display:none"{/if}>
								<label class="layui-form-label">分红比例</label>
								<div class="layui-input-inline">
									<input type="text" name="info[areafenhongbl]" class="layui-input" value="{$info.areafenhongbl}">
								</div>
								<div class="layui-form-mid">%</div>
								<div class="layui-form-mid layui-word-aux">区域代理的分红比例</div>
							</div>
						</div>
  {if getcustom('plug_sanyang')}
  <style>
	  .level-box { border-bottom: 1px solid #ddd; margin: 10px 0; width: 1000px;}
  </style>
  {if $levelExtendList}
  {foreach $levelExtendList as $levelExtend}
  <div class="level-box">
	  <div class="layui-form-item">
		  <label class="layui-form-label">扩展等级</label>
		  <div class="layui-input-inline">
			  <select name="record[levelid]" class="levelid" lay-verify="required">
				  <option value="0">请选择</option>
				  {foreach $level_category_extend as $v}
				  <optgroup label="{$v.name}">
					  {foreach $v['level_list'] as $level}
					  <option value="{$level.id}" {if $level['id'] == $levelExtend['levelid']}selected{/if}>{$level.name}</option>
					  {/foreach}
				  </optgroup>
				  {/foreach}
			  </select>
		  </div>
		  <div>
			  <div class="layui-form-mid">有效期</div>
			  <div class="layui-input-inline" id="level_extend_endtime_div" style="{if $info['level_extend_endtime']==0}display:none{/if}">
				  <input type="text" name="record[levelendtime]" id="level_extend_endtime" autocomplete="off" class="layui-input" value="{$levelExtend['levelendtime'] > 0 ? date('Y-m-d',$levelExtend['levelendtime']) : ''}">
			  </div>
			  <div class="layui-input-inline">
				  <input type="checkbox" name="level_extend_cq" value="1" {if $levelExtend['levelendtime']==0}checked{/if} title="长期" lay-filter="level_extend_cq"/>
			  </div>
		  </div>
	  </div>
	  <div class="layui-form-item">
		  <label class="layui-form-label">区域代理</label>
		  <div class="layui-input-inline" style="width:700px">
			  <input type="radio" name="record[areafenhong]" value="0" lay-filter="areafenhongChange" {if $levelExtend['areafenhong']==0}checked{/if} title="跟随会员等级设置"/>
			  <input type="radio" name="record[areafenhong]" value="1" lay-filter="areafenhongChange" {if $levelExtend['areafenhong']==1}checked{/if} title="省级代理"/>
			  <input type="radio" name="record[areafenhong]" value="2" lay-filter="areafenhongChange" {if $levelExtend['areafenhong']==2}checked{/if} title="市级代理"/>
			  <input type="radio" name="record[areafenhong]" value="3" lay-filter="areafenhongChange" {if $levelExtend['areafenhong']==3}checked{/if} title="区县代理"/>
			  <input type="radio" name="record[areafenhong]" value="4" lay-filter="areafenhongChange" {if $levelExtend['areafenhong']==4}checked{/if} title="非区域代理"/>
		  </div>
	  </div>
	  <div class="layui-form-item areafenhong_address" {if ($levelExtend['areafenhong']==0 && $levelArr[$levelExtend['levelid']]['areafenhong']==0) || $levelExtend['areafenhong']==4}style="display:none"{/if}>
		  <label class="layui-form-label">代理区域</label>
		  <div class="layui-input-inline">
			  <select name="record[areafenhong_province]" id="areafenhong_province_{$levelExtend.id}" lay-filter="areafenhong_province_{$levelExtend.id}"></select>
		  </div>
		  <div class="layui-input-inline areafenhong_city_div" {if ($levelExtend['areafenhong']==0 && !in_array($levelArr[$levelExtend['levelid']]['areafenhong'],[2,3])) || $levelExtend['areafenhong']==1}style="display:none"{/if}>
		  	<select name="record[areafenhong_city]" id="areafenhong_city_{$levelExtend.id}" lay-filter="areafenhong_city_{$levelExtend.id}"></select>
		  </div>
		  <div class="layui-input-inline areafenhong_area_div" {if ($levelExtend['areafenhong']==0 && $levelArr[$levelExtend['levelid']]['areafenhong']!=3) || in_array($levelExtend['areafenhong'],[1,2])}style="display:none"{/if}>
		  	<select name="record[areafenhong_area]" id="areafenhong_area_{$levelExtend.id}"></select>
		  </div>
	  </div>
	  <div class="layui-form-item areafenhong_bili" {if !in_array($levelExtend['areafenhong'],[1,2,3])}style="display:none"{/if}>
		  <label class="layui-form-label">分红比例</label>
		  <div class="layui-input-inline">
			  <input type="text" name="record[areafenhongbl]" class="layui-input" value="{$levelExtend.areafenhongbl}">
		  </div>
		  <div class="layui-form-mid">%</div>
		  <div class="layui-form-mid layui-word-aux">区域代理的分红比例</div>
	  </div>
  </div>
  <input type="hidden" name="record[id]" value="{$levelExtend['id']}" >

 {/foreach}
  {else}
  <div class="level-box">
	  <div class="layui-form-item">
		  <label class="layui-form-label">扩展等级</label>
		  <div class="layui-input-inline">
			  <select name="record[levelid]" lay-verify="required">
				  <option value="0">请选择</option>
				  {foreach $level_category_extend as $v}
				  <optgroup label="{$v.name}">
					  {foreach $v['level_list'] as $level}
					  <option value="{$level.id}" {if $level['id'] == $levelExtend['id']}selected{/if}>{$level.name}</option>
					  {/foreach}
				  </optgroup>
				  {/foreach}
			  </select>
		  </div>
		  <div>
			  <div class="layui-form-mid">有效期</div>
			  <div class="layui-input-inline" id="level_extend_endtime_div" style="{if $info['level_extend_endtime']==0}display:none{/if}">
				  <input type="text" name="record[levelendtime]" id="level_extend_endtime" autocomplete="off" class="layui-input" value="{$levelExtend['levelendtime'] > 0 ? date('Y-m-d',$levelExtend['levelendtime']) : ''}">
			  </div>
			  <div class="layui-input-inline">
				  <input type="checkbox" name="record[level_extend_cq]" value="1" {if $levelExtend['levelendtime']==0}checked{/if} title="长期" lay-filter="level_extend_cq"/>
			  </div>
		  </div>
	  </div>
	  <div class="layui-form-item">
		  <label class="layui-form-label">区域代理</label>
		  <div class="layui-input-inline" style="width:700px">
			  <input type="radio" name="record[areafenhong]" value="0" lay-filter="areafenhongChange" {if $record['areafenhong']==0}checked{/if} title="跟随会员等级设置"/>
			  <input type="radio" name="record[areafenhong]" value="1" lay-filter="areafenhongChange" {if $record['areafenhong']==1}checked{/if} title="省级代理"/>
			  <input type="radio" name="record[areafenhong]" value="2" lay-filter="areafenhongChange" {if $record['areafenhong']==2}checked{/if} title="市级代理"/>
			  <input type="radio" name="record[areafenhong]" value="3" lay-filter="areafenhongChange" {if $record['areafenhong']==3}checked{/if} title="区县代理"/>
			  <input type="radio" name="record[areafenhong]" value="4" lay-filter="areafenhongChange" {if $record['areafenhong']==4}checked{/if} title="非区域代理"/>
		  </div>
	  </div>
	  <div class="layui-form-item areafenhong_address" style="display:none">
		  <label class="layui-form-label">代理区域</label>
		  <div class="layui-input-inline">
			  <select name="record[areafenhong_province]" id="areafenhong_province_0" lay-filter="areafenhong_province_0"></select>
		  </div>
		  <div class="layui-input-inline areafenhong_city_div"style="display:none">
		  	<select name="record[areafenhong_city]" id="areafenhong_city_0" lay-filter="areafenhong_city_0"></select>
		  </div>
		  <div class="layui-input-inline areafenhong_area_div" style="display:none">
	          <select name="record[areafenhong_area]" id="areafenhong_area_0"></select>
		  </div>
	  </div>
	  <div class="layui-form-item areafenhong_bili" style="display:none">
		  <label class="layui-form-label">分红比例</label>
		  <div class="layui-input-inline">
			  <input type="text" name="record[areafenhongbl]" class="layui-input" value="0">
		  </div>
		  <div class="layui-form-mid">%</div>
		  <div class="layui-form-mid layui-word-aux">区域代理的分红比例</div>
	  </div>
  </div>

  {/if}
  {/if}

						<div class="layui-form-item">
							<label class="layui-form-label">推荐人ID</label>
							<div class="layui-input-inline">
								<input type="text" name="info[pid]" class="layui-input" value="{$info.pid}">
							</div>
							<div class="layui-form-mid layui-word-aux">无推荐人请填写0</div>
						</div>
						{if $info['tel']}
						<div class="layui-form-item">
							<label class="layui-form-label">登录密码</label>
							<div class="layui-input-inline">
								<input type="text" name="info[pwd]" autocomplete="off" class="layui-input" value="" placeholder="留空表示不修改密码">
							</div>
						</div>
						{/if}
						<div class="layui-form-item">
							<label class="layui-form-label">支付密码</label>
							<div class="layui-input-inline">
								<input type="text" name="info[paypwd]" autocomplete="off" class="layui-input" value="{$info['paypwd']}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">备注</label>
							<div class="layui-input-inline">
								<input type="text" name="info[remark]" class="layui-input" value="{$info['remark']}">
							</div>
						</div>

						{if getcustom('plug_luckycollage')}
						<div class="layui-form-item">
							<label class="layui-form-label">开团次数</label>
							<div class="layui-input-inline">
								<input type="text" name="info[ktnum]" class="layui-input" value="{$info['ktnum']}">
							</div>
						</div>
						{/if}

						{if getcustom('plug_businessqr')}
						<div class="layui-form-item">
							<label class="layui-form-label">绑定的店铺</label>
							<div class="layui-input-inline">
								<select name="info[bid]" lay-verify="required" lay-filter="yxqset">
									<option value="0">无</option>
									{foreach $blist as $v}
									<option value="{$v.id}" {if $v['id'] == $info['bid']}selected{/if}>{$v.name}</option>
									{/foreach}
								</select>
							</div>
						</div>
						{/if}
  					</div>
					<!--基本信息End-->
					<!--自定义信息start-->
 					 {if getcustom('register_fields')}
  					<input type="hidden" name="formdata[id]" value="{$register_record.id}">
  					<div class="layui-tab-item">
						{volist name="register_record.content" id="item" key="key"}
						{php}
							$formkey = 'form'.($key-1);
							$val = $register_record['form'.($key-1)]??'';
						{/php}
						{if $item.key=='input'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								<input type="text" name="formdata[{$formkey}]" class="layui-input" value="{$val}">
							</div>
						</div>
						{/if}
						{if $item.key=='textarea'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline" style="min-width: 300px">
								<textarea class="layui-textarea" name="formdata[{$formkey}]">{$val}</textarea>
							</div>
						</div>
						{/if}
						{if $item.key=='seletor'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								<select name="formdata[{$formkey}]" class="layui-select">
									<option name="">请选择</option>
									{volist name="item.val2" id="item2"}
									<option name="">{$item2}</option>
									{/volist}
								</select>
							</div>
						</div>
						{/if}
						{if $item.key=='radio'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								{volist name="item.val2" id="item2"}
									<label><input type="radio" name="formdata[{$formkey}]" title="{$item2}" value="{$item2}" {if $item2==$val}checked{/if}></label>
								{/volist}
							</div>
						</div>
						{/if}
						{if $item.key=='checkbox'}
						{php}
						$val = explode(',',$val);
						{/php}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline" style="min-width: 40%">
								{volist name="item.val2" id="item2"}
								<input type="checkbox" name="formdata[{$formkey}][]" value="{$item2}" title="{$item2}" {if in_array($item2,$val)}checked{/if}>
								{/volist}
							</div>
						</div>
						{/if}
						{if $item.key=='seletor'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								<select name="formdata[{$formkey}]" class="layui-select">
									<option name="">请选择</option>
									{volist name="item.val2" id="item2"}
									<option name="formdata[{$formkey}]" {if $item2==$val}selected{/if}>{$item2}</option>
									{/volist}
								</select>
							</div>
						</div>
						{/if}
						{if $item.key=='time'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								<input type="text" name="formdata[{$formkey}]" id="{$formkey}" class="layui-input timeinput" value="{$val}">
							</div>
						</div>
						{/if}
						{if $item.key=='date'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline">
								<input type="text" name="formdata[{$formkey}]" id="{$formkey}" class="layui-input dateinput" value="{$val}">
							</div>
						</div>
						{/if}
						{if $item.key=='upload'}
						<div class="layui-form-item">
							<label class="layui-form-label">{$item.val1}</label>
							<div class="layui-input-inline" style="min-width: 40%">
								<input type="hidden" name="formdata[{$formkey}]" id="formpic{$formkey}" class="layui-input" value="{$val}">
								<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="formpic{$formkey}" upload-preview="formpic{$formkey}Preview" onclick="uploader(this)">上传图片</button>
								<div id="formpic{$formkey}Preview" style="float:left;padding-top:10px;clear: both;">
									<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$val}"/></div></div>
								</div>
							</div>
						</div>
						{/if}
						{if $item.key=='region'}
						<div class="layui-form-item region_item" id="region{$customeKey}" data-text="{$val}">
							<label class="layui-form-label" >{$item.val1}：</label>
							<div class="layui-input-inline custom_province_div" style="width: 150px">
								<select name="formdata[{$formkey}][]" id="region{$customeKey}_province" lay-filter="region{$customeKey}_province"></select>
							</div>
							<div class="layui-input-inline custom_city_div" style="width: 150px">
								<select name="formdata[{$formkey}][]" id="region{$customeKey}_city" lay-filter="region{$customeKey}_area"></select>
							</div>
							<div class="layui-input-inline custom_area_div" style="width: 150px" style="display:none">
								<!--							<select name="custom[form{$customeKey}][]" id="region{$customeKey}_area"></select>-->
								<select name="formdata[{$formkey}][]" id="region{$customeKey}_area"></select>
							</div>
						</div>
						{/if}
						{/volist}
					</div>
  					{/if}
				    <!--自定义信息end-->
					<div class="layui-form-item">
					  <label class="layui-form-label"></label>
					  <div class="layui-input-block">
						  <button class="layui-btn" lay-submit lay-filter="memberedit">确认修改</button>
					  </div>
					</div>
					</div>
			   </div>
			</div>
		</div>
	</div>
</div>
</div>
  {include file="public/js"/}
	<script>
	var levelArr = {:jsonEncode($levelArr)};
	var defaultlevelid = "{$defaultlevel['id']}";
	layui.form.on('checkbox(levelcq)', function(data){
		if(data.elem.checked){
			$('#levelendtime_div').hide();
		}else{
			$('#levelendtime_div').show();
		}
	});
	layui.form.on('checkbox(level_extend_cq)', function(data){
		if(data.elem.checked){
			$('#level_extend_endtime_div').hide();
		}else{
			$('#level_extend_endtime_div').show();
		}
	});
	layui.form.on('select(yxqset)', function(data){
		var levelid = data.value
		if(levelid != defaultlevelid){
			$('#yxqset').show();
		}else{
			$('#yxqset').hide();
		}
		setareafenhong();
	});
	layui.form.on('radio(areafenhongChange)',function(data){
		setareafenhong(this);
	});
	function setareafenhong(e){
		var formdata = layui.form.val('form');
		var areafenhong = $(e).val();
		var levelid = $(e).parents('.level-box').find('.levelid').val();
		var parent = $(e).parents('.level-box');
		console.log(areafenhong)
		console.log(levelid)
		if((areafenhong==0 && levelArr[levelid].areafenhong != 0) || areafenhong==1 || areafenhong==2 || areafenhong==3 || areafenhong==10){
			parent.find('.areafenhong_address').show();
			parent.find('.areafenhong_largearea_div').hide();
			parent.find('.areafenhong_province_div').hide();
			parent.find('.areafenhong_city_div').hide();
			parent.find('.areafenhong_area_div').hide();
			if((areafenhong==0 && levelArr[levelid].areafenhong == 10) || areafenhong==10){
				parent.find('.areafenhong_largearea_div').show();
			}
			if((areafenhong==0 && levelArr[levelid].areafenhong == 1) || areafenhong==1){
				parent.find('.areafenhong_province_div').show();
			}
			if((areafenhong==0 && levelArr[levelid].areafenhong == 2) || areafenhong==2){
				parent.find('.areafenhong_province_div').show();
				parent.find('.areafenhong_city_div').show();
			}
			if((areafenhong==0 && levelArr[levelid].areafenhong == 3) || areafenhong == 3){
				parent.find('.areafenhong_province_div').show();
				parent.find('.areafenhong_city_div').show();
				parent.find('.areafenhong_area_div').show();
			}
		}else{
			parent.find('.areafenhong_address').hide();
		}
		if(areafenhong==0 || areafenhong==4){
			parent.find('.areafenhong_bili').hide();
		}else{
			parent.find('.areafenhong_bili').show();
		}
	}
	//日期范围选择
	layui.laydate.render({
		elem: '#levelendtime',
		trigger: 'click'
	});
	//日期范围选择
	layui.laydate.render({
		elem: '#level_extend_endtime',
		trigger: 'click'
	});
	//所有的时间控件
	$('.timeinput').each(function (e){
		var objId = $(this).attr('id');
		layui.laydate.render({
			elem: "#"+objId,
			type: 'time'
		})
	})
	//所有的日期控件
	$('.dateinput').each(function (e){
		var objId = $(this).attr('id');
		layui.laydate.render({
			elem: "#"+objId,
			type: 'date'
		})
	})


	address3('areafenhong_province','areafenhong_city','areafenhong_area',"{$info.areafenhong_province}","{$info.areafenhong_city}","{$info.areafenhong_area}");
	{if getcustom('plug_sanyang')}
	{if !$levelExtendList}
	address3('areafenhong_province_0','areafenhong_city_0','areafenhong_area_0',"","","");
	{/if}
	{foreach $levelExtendList as $levelExtend}
	address3('areafenhong_province_{$levelExtend.id}','areafenhong_city_{$levelExtend.id}','areafenhong_area_{$levelExtend.id}',"{$levelExtend.areafenhong_province}","{$levelExtend.areafenhong_city}","{$levelExtend.areafenhong_area}");
	{/foreach}
	{/if}

	{if !$register_record}
		$('.region_item').each(function (index,obj){
			var regionId = $(obj).attr('id');
			var areatext = $(obj).data('text');
			var provinceId = regionId+'_province';
			var cityId = regionId+'_city';
			var areaId = regionId+'_area';
			var provinceVal = '';
			var cityVal = '';
			var areaVal = '';
			if(areatext){
				var areaAry = areatext.split(',');
				if(areaAry.length>0){
					provinceVal = areaAry[0];
				}
				if(areaAry.length>1){
					cityVal = areaAry[1];
				}
				if(areaAry.length>2){
					areaVal = areaAry[2];
				}
			}
			address3(provinceId,cityId,areaId,provinceVal,cityVal,areaVal);
		})
	{/if}

	var upload = layui.upload;
  //执行实例
  var uploadInst = upload.render({
    elem: '#headimgupload' //绑定元素
    ,url: "{:url('upload/index')}" //上传接口
    ,done: function(res){
			console.log(res)
			$('#headimg').val(res.data)
			$('#headimgPreview').attr('src',res.data);
      //上传完毕回调
    }
    ,error: function(){
      //请求异常回调
    }
  });
	layui.form.on('submit(memberedit)', function(obj){
		var field = obj.field
		if(!field['levelcq']) field['levelcq'] = 0
		var index = layer.load();
		$.post("{:url('save')}",obj.field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					parent.layer.closeAll();
					parent.tableIns.reload()
				},1000)
			}
		})
	})
  </script>
	{include file="public/copyright"/}
</body>
</html>